<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>个股详情</title>
		<link href="/static/css/text.css" rel="stylesheet" type="text/css" />
		<style type="text/css">				
			p {margin:1px;}					
			ul {margin:1px;}			
			h4 {margin:0px}	
			#towriter{
				margin-top:-15px;
				border: 1px solid #555555;
				white-space: normal;											
			}
			.fixedBox{					
				white-space: nowrap;	
			}
			.fixedBox::-webkit-scrollbar {
				width: 8px;     
				height: 8px;				
			}
			table{
				width:380px; 
				border-collapse:collapse; 
				text-align:center;
			}
			td,th{border:1px solid #696969}	
		</style>		
		<script type="text/javascript" src="/static/js/json2html.js"></script>
		<script type="text/javascript" src="/static/js/jquery.min.js"></script>
		<script type="text/javascript" src="/static/DatePicker/WdatePicker.js"> </script>
	</head>
	<body>
		<h1></h1>
		<div id="stock_code" style="display: none">{{ stock_code }}</div>
		<div id="stock_name" style="display: none">{{ stock_name }}</div>
		<div id="towriter" class="fixedBox">
			<div id="towrite1" ></div>
			<div id="towrite" style="margin-top:-10px">				
				<!-- <div id="towrite2" style="border: 1px solid #E5E5E5; float: left;"></div> -->
				<div id="towrite2" class="fixedBox" style="position:relative; float:left;"></div>
				<div id="towrite3" class="fixedBox" style="position:relative; float:left;"></div>			
			</div>
		</div>
		<script>	
			var bkcolor = $("body").css("backgroundColor");
			var ztxq = 0;  //默认显示涨停原因(0:不显示；1:显示)
			var sdxq = 0;  //默认显示同花顺速递(0:不显示；1:显示)
			var rdxq = 0;  //默认显示东财热点(0:不显示；1:显示)
			var cgbk = 0; // 默认不显示常规板块(0:不显示；1:显示)
			
			var dt = ""; // 今天：2024-04-06
			var tt = ""; // 最后交易日：2024-04-06
			var gt = ""; // 今天时间戳：1712394929185
			var k9 = "0";
			
			var fenshi1 = "";
			var fenshi2 = "";
			var typeSort = 6; // 默认6涨幅排序  （6：涨幅、9：换手Z、1：主力净额）
			var bksl = 0; // 默认0为2个板块，1为全部板块
			
			window.onload = function() {
				var day = new Date();
				gt = day.getTime();
				mymonth = day.getMonth()+1;
				myday = day.getDate();
				if(mymonth >= 10){mymonth = mymonth;}else{mymonth = "0" + mymonth;}
				if(myday >= 10){myday = myday;}else{myday = "0" + myday;}
				tt = day.getFullYear() + "-" + mymonth + "-" + myday;	
				dt = tt;
				getSource();
				changeStyle();
			}
			
			var z = "1"; //自动刷新按钮
			$(function() {
				setInterval(function() {
					if(z == "1")
					{					
						getSource();										
					}					
				},
				1000);
			})
			

			
			function time_range(beginTime, endTime) {
				var strb = beginTime.split(":");
				if (strb.length != 2) {
					return false;
				}

				var stre = endTime.split(":");
				if (stre.length != 2) {
					return false;
				}

				var b = new Date();
				var e = new Date();
				var n = new Date();

				b.setHours(strb[0]);
				b.setMinutes(strb[1]);
				e.setHours(stre[0]);
				e.setMinutes(stre[1]);

				if (n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {
					hqsx();					
					console.log(true)　　　　　　
					return true;				
				} else {
					console.log(false)
				    return false;     
				}
			}　　　
			

			//同股状态下刷新
			$(function() {
				setInterval(function() {
					if(z == "1" && k == 0 && q == 0)
					{	
						time_range("9:00","15:15")					
						hqsx();										
					}					
				},
				60000);
			})
			Date.prototype.Format = function (fmt) {
				var o = {
					"M+": this.getMonth() + 1, //月份
					"d+": this.getDate(), //日
					"h+": this.getHours(), //小时
					"m+": this.getMinutes(), //分
					"s+": this.getSeconds(), //秒
					"q+": Math.floor((this.getMonth() + 3) / 3), //季度
					"S": this.getMilliseconds() //毫秒
				};
				
				if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
					for (var k in o)
					if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
					return fmt;
			};
			
			var ds = 0;
			function hqsx() {
				ds = 1;
			}
			
			function cDayFunc(dp) { 
				var date = dp.cal.getNewDateStr();            
				BookingRmk(date);//调用其它函数并带上参数                
			}
			
			function cTimeFunc() {
			
				if(document.getElementById('tFunc').value === "开启"){
					fenshi1 = document.getElementById('fenshi1').value;
					fenshi2 = document.getElementById('fenshi2').value;
					document.getElementById('tFunc').value = "关闭";
				}else {
					fenshi1 = "";
					fenshi2 = "";
					document.getElementById('tFunc').value = "开启";
				}
			}
			
			function cTimeFunc5() {
				if(document.getElementById('tFunc5').value == "涨幅"){
					typeSort = 6;
					document.getElementById('tFunc5').value = "换手";
					return;
				}
				if(document.getElementById('tFunc5').value == "换手"){
					typeSort = 9;
					document.getElementById('tFunc5').value = "涨幅";
					return;
				}
			}
			function cTimeFunc6() {
				if(document.getElementById('tFunc6').value == "两个"){
					bksl = 0;
					document.getElementById('tFunc6').value = "全部";
					return;
				}
				if(document.getElementById('tFunc6').value == "全部"){
					bksl = 1;
					document.getElementById('tFunc6').value = "两个";
					return;
				}
			}
			
			function BookingRmk(date){         
				tt = date;
				var date1 = new Date(tt);
				var date2 = new Date(dt);						
				k9 = 0;
				if(date1.getTime() < date2.getTime()){			
					k9 = 1;
					tradeday();
				}								
				//getSource();	
				writeSource2()				
			}
			function tradeday() {  //判断最后交易日
				var day = new Date(tt);
				tt = day.Format("yyyy-MM-dd");
				var url = `http://localhost:8889/tradeday/${tt}`;
				fetch(url)
					.then(response => response.json())
					.then(data_result => {
						tt = data_result.date;
					})
					.catch(error => {
						console.error('Error:', error);
					});
			}
			/*
			function changeStyle() {
				var obj = document.getElementById("towriter");				
				obj.style.left= "0px"; 				
				obj.style.width= "380px";	
				//obj.style.height= "630px";		
				obj.style.fontSize="12px";	
				
				var obj1 = document.getElementById("towrite1");	//上部				
				obj1.style.fontSize="13px";	
				obj1.style.minHeight= "10px";  //最小高度，自动高度						
				
				var obj2 = document.getElementById("towrite2"); //左下
				obj2.style.left= "0px"; 				
				obj2.style.width= "160px";	
				obj2.style.height= "200px";	
				obj2.style.fontSize="12px";	
				obj2.style.marginTop= "-10px";
				
				var obj3 = document.getElementById("towrite3"); //右下
				obj3.style.left= "0px"; 
				obj3.style.width= "160px";
				obj3.style.height= "200px";
				obj3.style.fontSize ="12px";
				obj3.style.marginTop= "-10px";
				obj3.style.marginLeft = "2px";  
				obj3.style.whiteSpace= "nowrap"; 
			}	
			*/
			function changeStyle() {
				var obj = document.getElementById("towriter");				
				obj.style.left= "0px"; 				
				obj.style.width= "685px";	
				obj.style.height= "630px";		
				obj.style.fontSize="12px";	
				
				var obj1 = document.getElementById("towrite1");	//上部				
				obj1.style.fontSize="13px";	
				obj1.style.minHeight= "10px";  //最小高度，自动高度						
				
				var obj2 = document.getElementById("towrite2"); //左下
				obj2.style.left= "0px"; 				
				obj2.style.width= "215px";	
				obj2.style.height= "345px";	
				obj2.style.fontSize="12px";	
				obj2.style.marginTop= "-10px";
				
				var obj3 = document.getElementById("towrite3"); //右下
				obj3.style.left= "0px"; 
				obj3.style.width= "430px";
				obj3.style.height= "345px";
				obj3.style.fontSize ="12px";
				obj3.style.marginTop= "-10px";
				obj3.style.marginLeft = "2px";  
				obj3.style.whiteSpace= "nowrap"; 
			}				
			
			function keepTwoDecimal(num) {  
               var result = parseFloat(num);  
               if (isNaN(result)) {  
                   //alert('传递参数错误，请检查！');  
                   return false;  
               }  
               result = Math.round(num * 100) / 100;  
               return result;  
			};
			
			function NumberTransform(num) { 
				var result = +num || 0;
               if(Math.abs(num) > 100000000){
			    result = num / 100000000;
				result = result.toFixed(2) + "亿";
			   }else if(Math.abs(num) > 10000){
			    result = num/10000;
				result = result.toFixed(0) + "万";
			   }				   
               return result;  
			};			
			
			function changeCss(obj,id){				
				var alist = document.getElementById(id).getElementsByTagName("a");					
				for(var i = 0; i < alist.length; i++){				
					if(alist[i] == undefined){
						break;
					}
					alist[i].style.color = "#E5E5E5"; //给所有a标签赋原色
				}
				//ranking();
				obj.style.color = "#00FFFF"; //令当前标签高亮
							
			}
			
			
			//js日期比较( 要求日期格式：yyyy-mm-dd)
			 function DateBiJiao(firstDate, lastDate) {
				var arr = firstDate.split("-");
				var firsttime = new Date(arr[0], arr[1], arr[2]);
				var firsttimes = firsttime.getTime();

				var arrs = lastDate.split("-");
				var  lasttime = new Date(arrs[0], arrs[1], arrs[2]);
				var  lasttimes =  lasttime.getTime();

				if (firsttimes> lasttimes) {
					return false;
				}
				else
					return true;
			}
			
			var k = 0;
			var gpdm = "";
			var gpmc = "";				
			function getSource() {	    
				//var u = decodeURI(window.location.href);
				//var stock_code = "{{stock_code}}";
				//var stock_name = {{stock_name}}";
				var stock_code = document.getElementById("stock_code").innerText;
				var stock_name = document.getElementById("stock_name").innerText;
				var u = "test##" + stock_code + "##" + stock_name
				if(u.indexOf("##") > -1){
					var gp = u.split('##');				
					dm = gp[1];
					gpmc = gp[2];					
					//alert(dm);
					if(dm == gpdm){
						k = 0;
					}else{
						k = 1;
						temp1 = "";	
						temp2 = "";
					}				
				}else{
					dm = "600000";
					gpmc = "浦发银行";
					k = 1;
					temp1 = "";	
					temp2 = "";
				}
				
				if(dm != gpdm){
					gpdm = dm;
					
					//gpdm = "002466";
					//alert(dm);
					if(k == 1 || ds == 1)	
					{
						ds = 0;
						var sc = "";
						if(gpdm.substr(0 , 1) == "6"){
							//sc = ".SH";
							sc = "17";
						}
						else{
							//sc = ".SZ";
							sc = "33";
						}
						if(dm.substr(0,1)=="6"){
							dms = dm + ".SS";
						}else{
							dms = dm + ".SZ";
						}

						writeSource1(gpdm,sc,dms)
						writeSource2(gpdm,sc,dms)
					}

				}
			}
			
			var yy = "";	
			var bk2g = "";
			var bk2gdm = "";

			function writeSource1(gpdm,sc,dms){
				// 构造请求 URL
            	var url = `http://localhost:8889/writeSource1/${gpdm}/${sc}/${dms}`;
				fetch(url)
					.then(response => response.json())
					.then(data_result => {
						var data1 = JSON.stringify(data_result.xmlHttp11);
						var data2 = JSON.stringify(data_result.xmlHttp12);
						var data3 = JSON.stringify(data_result.xmlHttp14);
						var data = data1;
						var title = "涨停原因：";
						if(data1.indexOf('"Type":"1"') > -1){
							title = "大涨原因：";
						}

						// 修改后的原因：大涨原因板块
						var dzReason = "";
						if(data1.indexOf('"List":[]') <= -1){
							for(var dzCode in JSON.parse(data1).List[0].ZSCode) {
							for (var jxbk in JSON.parse(data3).List) {
								if (JSON.parse(data3).List[jxbk].CCode == JSON.parse(data1).List[0].ZSCode[dzCode]) {
									if(dzCode == 0) {
										dzReason = dzReason + JSON.parse(data3).List[jxbk].CName
									}
									if(dzCode == 1) {
										dzReason = dzReason + '+' + JSON.parse(data3).List[jxbk].CName
									}

								}
							}
						}
						}




						if(data2.indexOf('"List":[]') == -1){   //his不为空
							//if(data1.indexOf('"List":[]') > -1 || data1.indexOf('"Reason":false') > -1){  //hq为空 或 "Reason":false
							if(data1.indexOf('"List":[]') > -1){  //hq为空
								data = data2;
								title = "前次涨停原因：";
								if(data2.indexOf('"Type":"1"') > -1){
									title = "前次大涨原因：";
								}
							}
						}



						//document.write(data);
						var transform_aa = [
						{"tag":"ul", children:function(){return(json2html.transform(this.List[0], transform_bb));}}
						];

						var ztyy = "";
						yy = "";
						var transform_bb=
							{"tag":"p", children:function(){
							var jx = "<td><a style='position:absolute; right:30px;' href='javascript:void(0)' onclick='updates()'>" + "详情" + "</a></td>";
							// 原本的原因
							yy = this.Reason;
							if(yy != false){
								yy = yy.split('；')[0]
							}else{
								yy = dzReason;
							}
							ztyy = 	this.GNSM;
							if(this.Date == dt){
								return("<b style='color:#fff'>" + this.Date + "：" + yy + "&nbsp;&nbsp;&nbsp;&nbsp;" + this.SCLT + jx + "</b>");
							}else{
								return("<b>" + this.Date + "：" + yy + "&nbsp;&nbsp;&nbsp;&nbsp;" + this.SCLT + jx + "</b>");
							}
							}};

						var html = json2html.transform(data, transform_aa);
						div = document.getElementById('towrite1');
						var sx = "<a style='float:right'  href='javascript:void(0)' id='sx' onclick='updatex()'>停止刷新</a>";
						var sjzj = '<font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><input style="width: 120px;" type="text" id="PriceDate" name="PriceDate" class="Wdate" onFocus="WdatePicker({ onpicking: cDayFunc})" />';	 // 时间组件
						var qj = '区间:<input style="width: 35px;" type="text" id="fenshi1" value="0925"  )" /> <input style="width: 35px;" type="text" id="fenshi2" value="0930"  )" /> <input type="button" id="tFunc" value="开启" onclick="cTimeFunc()"/>';// 区间
						var pxt = '排序: <input type="button" id="tFunc5" value="涨幅" onclick="cTimeFunc5()"/>'; // 排序类型
						var bkslElement = '<input type="button" id="tFunc6" value="两个" onclick="cTimeFunc6()"/>'; // 板块数量：默认显示2个
						//var jbm = "<a href='http://www.treeid/dlglocalurl##homepath##company/" + encodeURI('基本面') + ".html##xxxxxx####STOCKNAME##' style='float:right;font-size:14px;'>基本面</a>";
						var jbm = "";
						// 个股板块(取前两个)
						var data5 = JSON.stringify(data_result.xmlHttp15);
						var data5Result = JSON.parse(data5);
						bk2g = "";
						bk2g = data5Result.ListJX[0][1] + "、" + data5Result.ListJX[1][1];
						bk2gdm = data5Result.ListJX[0][0] + "、" + data5Result.ListJX[1][0];
						// 个股亮点
						var data6 = JSON.stringify(data_result.xmlHttp16);
						var data6Result = JSON.parse(data6).data.text;
						//var ggld = '<ul style="width:500px;white-space:nowrap;overflow:auto;scrollbar-height:none;::-webkit-scrollbar{display:none}"><b>个股亮点:'+data6Result+'</b></ul>';
						var ggld = '<ul style="white-space:nowrap;" >亮点:<b style="color:#00FFFF;">'+data6Result+'</b></ul>';

						div.innerHTML = '<b>个股详情：' + gpdm + "&nbsp;&nbsp;&nbsp;" + gpmc + sjzj + qj + pxt + bkslElement + '&nbsp;'+sx + jbm +'</b>'+ggld+'<ul><b>' + title + '</b>' +"<b style='float:right'>" + '精选板块:'+bk2g+ "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+"</b>"+ '</ul>' + html;

						//添加分类Div
						var newDiv1 = document.createElement("div");
						newDiv1.id = "xq";
						newDiv1.style.display = "none";
						document.getElementById("towrite1").appendChild(newDiv1);
						div1 = document.getElementById("xq");
						div1.innerHTML += "<p>" + ztyy + "</p>" ;
						temp1 = "";


						function up(a,b){
							var aa = a.ctime;
							var bb = b.ctime;
							if(a.catename == "涨停分析"){
								aa = 0;
							}
							if(b.catename == "涨停分析"){
								bb = 0;
							}
							return aa - bb
						}
						// //同花顺速递
						// var data3 = xmlHttp13.responseText;
						// data3 = data3.replace(/\s+/g,"；");
						// data3 = data3.match(/"events":(\S*)}]/)[1] + "}]";
						//
						// var result = JSON.parse(data3); //JSON字符串转换为对象
						// result.sort(up);
						// result = JSON.stringify( result );
						// data3= '{\"data\":' + result + "}";
						// //document.write(data3);
						//
						// xqs = data3.split('},{');
						// var dq = "<td><a style='position:absolute; right:30px;' href='javascript:void(0)' onclick='updatest()'>" + "详情" + "</a></td>";
						// div.innerHTML += "<ul><b>同花顺速递：（" + xqs.length + "项）" + dq + "</b></ul>";
						//添加分类Div
						var newDiv3 = document.createElement("div");
						newDiv3.id = "txq";
						newDiv3.style.display = "none";
						document.getElementById("towrite1").appendChild(newDiv3);
						div3 = document.getElementById("txq");

						var transform_aa1 = [
						{"tag":"p", children:function(){return(json2html.transform(this.data, transform_bb1));}}
						];

						<!-- var transform_bb1 = [            -->
						<!-- {"tag":"p", children:function(){return(json2html.transform(this.events, transform_cc1));}} -->
						<!-- ]; -->

						var transform_bb1=
						{"tag":"ul style=color:#FFA500;", children:[
						{"tag": "li style=color:#00FFFF;", "html":"${catename}： ${date}"},
						{"tag": "p", "html": function(){
							if(this.catename == "涨停分析"){
								return(this.title.replace("涨停分析:","").replace("｜","：<br>"));
							}else{
								return(this.content);
							}
						}},
						//{"tag": "p", "html":"${title}"},
						//{"tag": "p", "html":"${content}"},
						{"tag": "p style=color:#FFF5EE;", "html":"${desc}"},
						]};

						var html1 = json2html.transform(data3, transform_aa1);
						div3.innerHTML += html1;
						temp12 = "";

						if(ztxq == 1 && ztyy != ""){  //显示涨停原因
							updates();
						}
						if(sdxq == 1){    //显示同花顺速递
							updatest();
						}
					})
					.catch(error => {
						console.error('Error:', error);
					});
        	}

			

			var temp1 = "";					
			function updates() {			
				if(document.getElementById("xq")){					
					div1 = document.getElementById("xq");
					if(temp1.indexOf("xq") == -1){
						temp1 += "xq" + ";";
						div1.style.display = "block";
						div1.style.border="1px solid #999";
						div1.style.color = "#FFA500";
					}else{
						temp1 = temp1.replace("xq" + ";" , "");
						div1.style.display = "none";
					}
				}
				if(temp1 == ""){  //查看详情时不刷新				
					q = 0;
				}else{
					q = 1;
				}				
			}
			
			var temp12 = "";					
			function updatest() {			
				if(document.getElementById("txq")){					
					div12 = document.getElementById("txq");
					if(temp12.indexOf("txq") == -1){
						temp12 += "txq" + ";";
						div12.style.display = "block";
						div12.style.border="1px solid #999";						
					}else{
						temp12 = temp12.replace("txq" + ";" , "");
						div12.style.display = "none";
					}
				}
				if(temp12 == ""){  //查看详情时不刷新				
					q = 0;
				}else{
					q = 1;
				}				
			}
			
			
			var temp2 = "";	
			var q = 0;			
			function updatexq(ss) {	
				if(document.getElementById(ss)){					
					div2 = document.getElementById(ss);
					if(temp2.indexOf(ss) == -1){
						temp2 += ss + ";";
						div2.style.display = "block";
						div2.style.whiteSpace = "normal";
						div2.style.border="1px solid #999";
						div2.style.color = "#FFA500";
					}else{
						temp2 = temp2.replace(ss + ";" , "");
						div2.style.display = "none";
					}
				}
				if(temp2 == ""){  //查看详情时不刷新				
					q = 0;
				}else{
					q = 1;
				}
			}
			
			
			
			function updatex() {				
				aObj = document.getElementById('sx');
				if(aObj.innerText == "停止刷新"){
					z = "0";
					aObj.innerText = "自动刷新";
					aObj.style.color = "#ADFF2F";
				}else if(aObj.innerText == "自动刷新"){
					z = "1";
					aObj.innerText = "停止刷新";
					aObj.style.color = "#E5E5E5";					
				}
			}
						
			function updated() {			
				z = "0";			
				aObj = document.getElementById('sx');
				if(aObj.innerText == "停止刷新"){					
					aObj.innerText = "自动刷新";
					aObj.style.color = "#ADFF2F";
				}					
			}
			
			function UnUnicode(str) {
				return unescape(str.replace(/\\/g, "%"));
			}
			function writeSource2(gpdm,sc,dms) {
				// 构造请求 URL
            	var url = `http://localhost:8889/writeSource2/${gpdm}/${sc}/${dms}`;
				fetch(url)
					.then(response => response.json())
					.then(data_result => {
						div1 = document.getElementById('towrite2');
						div1.innerHTML = "<h4 style='color:#FFFF00'>精选板块</h4>";
						var data = JSON.stringify(data_result.xmlHttp21);
						data = data.replace(/ /g,"");
						data = data.replace(/(\[\").*?(?=\])/g,function(word){
						str = word.match(/\[(\S*)/)[1];
						//str = word;
						return '{"code":' + str.split(',')[0] +
						',"name":' + str.split(',')[1] +
						',"zf":' + str.split(',')[2] ;});
						data = data.replace(/\[\[/g,'[{').replace(/\]\]/g,"}]").replace(/],{/g,"},{");
						data = data.match(/(\S*)],"ttag/)[1];
						//document.write(data);
						var data1 = JSON.stringify(data_result.xmlHttp22);
						data1 = data1.replace(/ /g,"");
						data1 = UnUnicode(data1);
						data1 = data1.replace(/\s+/g,"");
						data1 = data1.match(/(\S*)],\"errcode/)[1];
						//document.write(data1);
						var bks = "";
						var gn = data1.split('},{');
						//var m = 1;
						for (i = 0; i < gn.length; i++){
							var code = gn[i].match(/\"CCode\":\"(\S*)\",\"Analysis/)[1];
							if(data.indexOf(code) == -1){
								var name = gn[i].match(/\"CName\":\"(\S*)\"/)[1];
								data += ',{"code":"' + code + '","name":"' + name + '","zf":null}';
							 }
						}
						data = data + "]";
						//document.write(data);
						ss = data.split('},{');
						for (i = 0; i < ss.length; i++){
							var code = ss[i].match(/\"code\":\"(\S*)\",\"name/)[1];
							var name = ss[i].match(/\"name\":\"(\S*)\",\"zf/)[1];
							var tempName = ss[i].match(/\"name\":\"(\S*)\",\"zf/)[1];
							name = UnUnicode(name);
							var zf = "";
							if(i != ss.length - 1){
								zf = ss[i].match(/\"zf\":(\S*)/)[1];
							}else{
								zf = ss[i].match(/\"zf\":(\S*)\}\]/)[1];
							}
							var zfs = "";
							if(zf != 'null'){
								//zfs = "&nbsp;涨幅：" + zf + "%";
								zfs = "&nbsp;:" + zf + "%";
							}

							bks = "<a href='javascript:void(0)' id='" + name + "' onclick='changeCss(this,\"towrite2\");update(" + "\"" +
										code + "\"+\"#\"+" + "\"" + name + "\"" + ")'>" + ( i + 1) + "、" +
										 "&nbsp;" + name + zfs + "</a>"	;
							var jx = "<td><a href='javascript:void(0)' onclick='updatexq(888" + code + ")'>" + "详情" + "</a> <a style='color:red' href='http://www.treeid/dlglocalurlD:/apps/炒股软件/通达信/company/kpl-K线分时走势图.html##" + code + "##" + encodeURI(name)+ "'>K线</a></td>";
							bks = bks + jx;
							var xq = "";
							if(data1.indexOf(code) > 0){
								//alert(code);
								var s = data1.split(code)[1];
								//alert(s);
								var k1 = s.indexOf("\"Analysis\":\"");
								var k2 = s.indexOf("}");
								xq = s.substring(k1,k2);
								xq = xq.match(/\"Analysis\":\"(\S*)\",\"CName/)[1];
								if(xq == ""){
									xq = "暂无";
								}
							}else{
								xq = "暂无";
							}
							var bkdm = code;
							if(bksl == 0){
								if(code == bk2gdm.split('、')[0] ||  code == bk2gdm.split('、')[1] || name == yy.split('+')[0] ||  name == yy.split('+')[1]){
									subclass(bkdm , bks , xq, true);
								}
							} else {
								subclass(bkdm , bks , xq);
							}

							if (code == bk2gdm.split('、')[0] && y == 1){
								temp = code + ";";
								update(code + "#" + name);
							}
						}

						document.getElementById("PriceDate").value = tt;
						//变色
						var interval = setInterval(function() {
							if(yy != "" || bk2g!=""){
								ranking();
								clearInterval(interval);
							}
						},300);

					})
					.catch(error => {
						console.error('Error:', error);
					});

			}

			
			//子类
			async function subclass(bkdm , bks, xq, colorFlag) {
				// 构造请求 URL
            	var url = `http://localhost:8889/subclass/${bkdm}`;
				await fetch(url)
					.then(response => response.json())
					.then(data_result => {

						div1 = document.getElementById('towrite2');
						var data3 = JSON.stringify(data_result.xmlHttp3_url3);
						if(data3.indexOf('\"List\":[]') == -1) {
							var dms = bks.split('、');
							div1.innerHTML += "<p>" + dms[0] + "、★" + dms[1] + "</p>";
							//添加详情
							var newDiv1 = document.createElement("div");
							newDiv1.id = "888" + bkdm;
							newDiv1.style.display = "none";
							document.getElementById("towrite2").appendChild(newDiv1);

							div2 = document.getElementById("888" + bkdm);
							div2.innerHTML += xq;

							//添加分类Div
							var newDiv = document.createElement("div");
							newDiv.id = bkdm;
							newDiv.style.display = "none";
							document.getElementById("towrite2").appendChild(newDiv);

							//data3 = data3.replace(/ /g,"").match(/(\S*)\]\],\"/)[1] + ']]';
							data3 = data3.replace(/ /g,"").match(/\{\"List\":(\S*)\]\],\"/)[1] + ']]';
							data3 = data3.replace(/(\[\").*?(?=\])/g,function(word){ str = word.match(/\[(\S*)/)[1]; return '{"code":' + str.split(',')[0] + ',"name":' + str.split(',')[1]+',"qd":'+str.split(',')[2];});
							data3 = data3.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]");
							//alert(data3);
							//document.write(data3);

							var result = JSON.parse(data3); //JSON字符串转换为对象
							function up(a,b){
							return b.qd-a.qd
							}
							result.sort(up);
							result = JSON.stringify( result );
							data3= '{\"List\":' + result + "}";
							//document.write(data3);

							var transform_ee1 = [
							{"tag":"ul", children:function(){return(json2html.transform(this.List, transform_ff1));}}
							];

							var transform_ff1=
							{"tag":"p", children:[
							{"tag":"p", children:[
							{"tag": "li", "html":"<a href='javascript:void(0)' id='" + bkdm + "' onclick='changeCss(this,this.id);update(\"${code}\"+\"#\"+\"${name}\")'>${name}&nbsp;强度：${qd}</a>"}
							]}]};

							var html3 = json2html.transform(data3, transform_ee1);
							//div1 = document.getElementById('towrite1');
							var div = document.getElementById(bkdm);
							div.innerHTML += html3;
						}
						else
						{
							div1.innerHTML = div1.innerHTML + "<p>" + bks + "</p>";
							//添加详情
							var newDiv1 = document.createElement("div");
							newDiv1.id = "888" + bkdm;
							newDiv1.style.display = "none";
							newDiv1.style.whiteSpace = "normal";
							document.getElementById("towrite2").appendChild(newDiv1);

							div2 = document.getElementById("888" + bkdm);
							div2.innerHTML += xq;
						}

				})
				.catch(error => {
					console.error('Error:', error);
				});
			}
			
			var temp = "";
			var bdm = "";
			var bkm = "";
			var y = 1;	

			function dateback(rq,interval) {

				// 更新最后交易日
				tradeday();

				var day = new Date(rq);
				var dayStr = day.Format("yyyy-MM-dd");
				day.setTime(day.getTime() + 24*60*60*1000*interval);
				dayStr = day.Format("yyyy-MM-dd");
				return dayStr;
			}
			
			function back(ss) {						
				
				if(ss != "0"){
					var dms = ss.split('#');					
					bdm = dms[0]; // 板块代码：801396
					bkm = dms[1]; // 板块名词: 云游戏
					rq = dms[2]; // 日期
				}
				rq = dateback(rq,-1);
				tt = rq;
				var date1 = new Date(tt);
				var date2 = new Date(dt);						
				k9 = 0;
				if(date1.getTime() < date2.getTime()){			
					k9 = 1;
					tradeday();
				}	
				ss = bdm + '#' + bkm + '#' + rq;
				update(ss);
			}
			
			function forward(ss) {				
				if(ss != "0"){
					var dms = ss.split('#');					
					bdm = dms[0]; // 板块代码：801396
					bkm = dms[1]; // 板块名词: 云游戏
					rq = dms[2]; // 日期
				}
				rq = dateback(rq,1);
				tt = rq;
				var date1 = new Date(tt);
				var date2 = new Date(dt);						
				k9 = 0;
				if(date1.getTime() < date2.getTime()){			
					k9 = 1;
					tradeday();
				}	
				ss = bdm + '#' + bkm + '#' + rq;
				update(ss);
			}			
			function update(ss) {

				//alert(ss);
				y = 1;
				if(ss != "0"){
					var dms = ss.split('#');
					bdm = dms[0]; // 板块代码：801396
					bkm = dms[1]; // 板块名词: 云游戏
					rq = dms[2]; // 日期
					if (rq == undefined || rq == '') {
						rq = tt;
					}

					//alert(temp);
					if(document.getElementById(bdm)){
						div1 = document.getElementById(bdm);
						if(temp.indexOf(bdm) == -1){
							temp += bdm + ";";
							div1.style.display = "block";
							div1.style.border = "1px solid #646464";
						}else{
							temp = temp.replace(bdm + ";" , "");
							div1.style.display = "none";
						}
					}
					//alert(temp);
				}
				//alert(bdm);
				var bfyy = "<a style='padding-left:0px' href='javascript:void(0)' onclick='updateb()'>【原因】</a>";
				var zz = "<a style='padding-left:10px' href='javascript:void(0)' onclick='updatez()'>最正宗</a>";
				ss = bdm + '#' + bkm + '#' + rq;
				var back = '<a href="javascript:back(' + '\'' + ss +'\''+');"  style="color:#fff">←</a>'
				var forward = '<a href="javascript:forward(' + '\'' + ss +'\''+');"  style="color:#fff">→</a>'
				div2 = document.getElementById('towrite3');
				//div2.innerHTML = '<h4>' + bkm + zz + '</h4>';
				div2.innerHTML = '<b>' + bkm +  back + rq + forward + bfyy + zz +'</b>';

				// var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&a=ZhiShuStockList_W8&st=30&c=ZhiShuRanking&PhoneOSNew=1&old=1&DeviceID=037520ec-5c84-34a1-8d7a-813a91437308&VerSion=5.13.0.0&IsZZ=0&Index=0&apiv=w35&Type=6&IsKZZType=0&PlateID=" + bdm + "&";
				// var url2 = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=ZhiShuStockList_W8&st=30&c=ZhiShuRanking&PhoneOSNew=1&old=1&DeviceID=00000000-20e2-de83-0000-000075d2bc63&VerSion=5.10.0.2&IsZZ=0&Token=eae05af9b2237485e90e8165e55b0f20&Index=0&Date="+ rq +"&apiv=w33&Type=6&IsKZZType=0&UserID=1904945&PlateID=" + bdm + "&";
				// var url = url1;
				// if(k9 == "1"){
				// 	url = url2;
				// }
				//
				// if(k9 == "0"){
				// 	if(fenshi1 != "" && fenshi2 != ""){
				// 		url =  "https://apphq.longhuvip.com/w1/api/index.php?Order=1&a=ZhiShuStockList_W8&st=30&c=ZhiShuRanking&PhoneOSNew=1&RStart=" + fenshi1 + "&old=1&DeviceID=037520ec-5c84-34a1-8d7a-813a91437308&VerSion=5.13.0.0&IsZZ=0&Token=0&Index=0&REnd=" + fenshi2 + "&apiv=w35&Type="+typeSort+"&IsKZZType=0&UserID=0&PlateID=" + bdm + "&";
				//
				// 	} else {
				// 		url = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&a=ZhiShuStockList_W8&st=30&c=ZhiShuRanking&PhoneOSNew=1&old=1&DeviceID=037520ec-5c84-34a1-8d7a-813a91437308&VerSion=5.13.0.0&IsZZ=0&Index=0&apiv=w35&Type="+typeSort+"&IsKZZType=0&PlateID=" + bdm + "&";
				//
				// 	}
				//
				// }else{
				// 	if(fenshi1 != "" && fenshi2 != ""){
				// 		url = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=ZhiShuStockList_W8&st=30&Index=0&c=ZhiShuRanking&PhoneOSNew=1&old=1&DeviceID=00000000-20e2-de83-0000-000075d2bc63&VerSion=5.10.0.2&IsZZ=0&Token=eae05af9b2237485e90e8165e55b0f20&Date="+ rq +"&apiv=w33&Type="+typeSort+"&IsKZZType=0&UserID=1904945&PlateID=" + bdm+ "&RStart=" + fenshi1 + "&REnd=" + fenshi2+ "&";
				// 	} else {
				// 		url = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=ZhiShuStockList_W8&st=30&Index=0&c=ZhiShuRanking&PhoneOSNew=1&old=1&DeviceID=00000000-20e2-de83-0000-000075d2bc63&VerSion=5.10.0.2&IsZZ=0&Token=eae05af9b2237485e90e8165e55b0f20&&Date="+ rq +"&apiv=w33&Type="+typeSort+"&IsKZZType=0&UserID=1904945&PlateID=" + bdm+ "&";
				// 	}
				// }
				//
				//
				// var url1_1025 = "https://apphq.longhuvip.com/w1/api/index.php?a=GetPlate_Info_QJ&apiv=w33&c=ZhiShuRanking&PhoneOSNew=1&PlateID="+ bdm +"&Date=&"
				//
				// var url2_1025 = "https://apphis.longhuvip.com/w1/api/index.php?a=GetPlate_Info_QJ&apiv=w33&c=ZhiShuRanking&PhoneOSNew=1&PlateID="+ bdm +"&Date=" + rq + "&"
				// var url_1025 = url1_1025;
				// if(k9 == "1"){
				// 	url_1025 = url2_1025;
				// }

				fetch(`http://localhost:8889/update/${bdm}/${rq}/${k9}/${fenshi1}/${fenshi2}/${typeSort}`)
				.then(response => response.json())
				.then(data_result => {
					var data2_1025 = JSON.stringify(data_result.url1025);
					var data2 = JSON.stringify(data_result.url);
					writeSource3(data2_1025,data2)
				})
				.catch(error => {
					console.error('Error:', error);
				});
			}
			
			function writeSource3(data2_1025,data2) {
					// 板块信息

					var data2_1025s = data2_1025.match(/\[(\S*)\]/)[1].split(",");
					
					var paiming = data2_1025s[0];//排名
					var qiangdu = data2_1025s[1];//强度
					var bkcje = NumberTransform(data2_1025s[2]);// 成交额
					var bkzlje = NumberTransform(data2_1025s[3]);// 主力净额
					var zhangfu = Number(data2_1025s[4]).toFixed(2); // 涨幅%	num.toFixed(2)
					var bkxxdiv = '<p style="margin-bottom:8px">' + bkm + " - " + "排名:" + paiming + " 强度:" + qiangdu + " 涨幅:" +zhangfu + "% 净额:" + bkzlje + '</p>' ;// 板块信息div
					// 板块信息 end

					
					//document.write(data2);
					//data2 = data2.replace(/ /g,"").match(/(\S*)\]\],\"/)[1] + ']]';	
					data2 = data2.replace(/ /g,"").match(/{"list":(\S*)/)[1].split("]]")[0] + ']]';	
					//data2 = data2.replace(/(\[\").*?(?=\])/g,function(word){ str = word.match(/\[(\S*)/)[1]; return '{"code":' + str.split(',')[0] + ',"name":' + str.split(',')[1]+',"zf":'+str.split(',')[6];});
					data2 = data2.replace(/(\[\").*?(?=\])/g,function(word){ 
					str = word.match(/\[(\S*)/)[1]; 
				

					return '{"code":' + str.split(',')[0] + 
					',"name":' + str.split(',')[1] +
					',"zf":'+str.split(',')[6] +
					',"st":'+str.split(',')[20] +
					',"lz":'+str.split(',')[24] +
					',"lb":'+str.split(',')[23] + 
					',"spfd":'+ "\"" + NumberTransform(str.split(',')[28]) + "\"" + // 收盘封单
					',"zdfd":'+ "\"" + NumberTransform(str.split(',')[29]) + "\"" +//最大封单
					',"cje":'+ "\"" + NumberTransform(str.split(',')[7]) + "\"" +// 成交额
					',"sjhs":'+ "\"" + keepTwoDecimal(str.split(',')[8]) + "%" + "\"" +// 实际换手
					//',"zs":'+keepTwoDecimal(str.split(',')[9]) +
					',"sjlt":'+ "\"" + NumberTransform(str.split(',')[10]) + "\"" + // 实际流通
					//',"zl":'+str.split(',')[2] +
					//',"zlje":'+ "\"" + NumberTransform(str.split(',')[13]) +"/"+ str.split(',')[19] + "%"+ "\"" +// 主力净额+净流占比
					',"zlje":'+ "\"" + NumberTransform(str.split(',')[13]) +"/"+ str.split(',')[16] + "%"+ "\"" +// 主力净额+净成占比
					//',"zlje":'+ "\"" + NumberTransform(str.split(',')[13]) + "\"" +// 主力净额
					//',"jlzb":'+ "\"" + str.split(',')[19] + "%" + "\"" + // 净流占比 
					',"zt":'+str.split(',')[39] + 
					',"bk":'+str.split(',')[4]
					;});
										
					data2 = data2.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]");					
					//document.write(data2);
					var json = JSON.parse(data2);
						
					//创建table					
					var table=document.createElement("table");										
					var thead=document.createElement("thead");
					table.appendChild(thead);					
					var tr=document.createElement("tr");
					thead.appendChild(tr);					
					
					var m = 0;
					var v = 0;
					var b = 0;
					var gl = "领涨";  //高亮
					for(var key in json[0]){  //表头													
						key = key.replace('code','代码').replace('name','名称').replace('zf','涨幅%').replace('st','实体%').replace('zlje','主力净额').replace('jlzb','净流占比').replace('spfd','收盘封单').replace('zdfd','最大封单').replace('sjlt','实际流通').replace('cje','成交额').replace('sjhs','实际换手');
						key = key.replace('lb','连板').replace('zt','主题').replace('zs','涨速%').replace('zl','主力').replace('lz','领涨').replace('bk','板块');
						var th=document.createElement("th");						
						th.innerHTML=key;						
						tr.appendChild(th);					
						if(key == "领涨" || key == "主力" || key == "连板" || key == "主题"){
							th.style.color = "#FFA500";	
						}
						if(gl == key.replace("%","")){
							v = m;
							th.style.color = "#FF6633";	
						}
						m++;
					}
										
					var tbody=document.createElement("tbody");					
					table.appendChild(tbody);
					
					//遍历json
					for(var i = 0; i < json.length; i++){					
						var tr=document.createElement("tr");						
						var p = 1;	
						var dm = "";
						var mc = "";					
						for(var key in json[i]){ //行元素遍历					
							var td=document.createElement("td");							
							
							var rc = json[i][key];
							if(p == 1){  //代码列
								dm = rc;
								tr.id = dm;
							}
							<!-- else if(p == 4){ -->
								<!-- rc = keepTwoDecimal(rc); -->
							<!-- }else if(p == 9){ -->
								<!-- rc = NumberTransform(rc); -->
							<!-- }						 -->
							// 分时图
							//td.innerHTML = "<a href=http://192.168.1.2:8080//kpl-K线分时走势图.html##" + dm + " id='" + p + "' onclick='updated();changeTCss(this,\"" + dm + "\",\"gg\")'>" + rc + "</a>";
							td.innerHTML = "<a href=http://www.treeid/code_" + dm + " id='" + p + "' onclick='updated();changeTCss(this,\"" + dm + "\",\"gg\")'>" + rc + "</a>";
							
							if(p > 4 && p < 9){							
								td.getElementsByTagName("a")[0].style.color = "#FFA500";
								td.width = "100px";								
							}
							if(p == v + 1){							
								td.getElementsByTagName("a")[0].style.color = "#FF6633";
							}	
							if(p == 3){
								// 涨幅颜色
								if(rc<-4) {
									td.getElementsByTagName("a")[0].style.backgroundColor = "#008000"; // 绿色
								}
								if(rc>7) {
									td.getElementsByTagName("a")[0].style.color = "#FF6633"; // 红色
								}
							}
							if(p == 4){
								// 实体颜色
								if(rc<0) {
									td.getElementsByTagName("a")[0].style.backgroundColor = "#008000"; // 绿色
								} else{
									td.getElementsByTagName("a")[0].style.color = "red"; // 红色
								}
							}
							
							tr.appendChild(td);
							p++;
						}						
						tbody.appendChild(tr);
					}					
					var div = document.getElementById("towrite3");
					div.style.whiteSpace = "nowrap";
					div.innerHTML = div.innerHTML + bkxxdiv;// 增加板块信息
					div.appendChild(table);
					table.id = "gg";					
					
					var table=document.getElementsByTagName("table")[0];
					makeSortable(table);		
					changeTable(table);		//隐藏某列	
					hover();

			}
			
			//隐藏某列				
            function changeTable(table) {
                var trs = table.rows;
                for (var i = 0, len = trs.length; i < len; i++) {
                    //var cell = trs[i].cells[0]; //隐藏第1列					
                    //cell.style.display = 'none';
                }
            }
			
			var trid = "";
			function changeTCss(obj,hid,id){
				var tlist = document.getElementById(id).getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){									
					tlist[i].style.backgroundColor = bkcolor; 					
				}
				trid = hid;
				var tr = document.getElementById(hid);				
				tr.style.backgroundColor = "#483D8B";						
			}
			
			function hover(){  //鼠标经过
				var rows = document.getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){						
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头
							if(this.id != trid){  //过滤选中行
								this.style.background=bkcolor;
							}else{
								this.style.background="#483D8B";
							}
						}						
					}					
				}
			}			
			
			var f = 1;
			function makeSortable(table) {
				var headers=table.getElementsByTagName("th");
				for(var i=0;i<headers.length;i++){				
					(function(n){
						var flag=false;
							
						headers[n].onclick=function(){							
							showCol(n);		//高亮
							var tbody=table.tBodies[0];
							var rows=tbody.getElementsByTagName("tr");
							rows=Array.prototype.slice.call(rows,0);

							//基于第n个<td>元素的值对行排序
							rows.sort(function(row1,row2){
								headtxt = headers[n].textContent;								
								var cell1=row1.getElementsByTagName("td")[n];//获得第n个单元格
								var cell2=row2.getElementsByTagName("td")[n];																
								var val1=cell1.textContent||cell1.innerText;//获得文本内容
								var val2=cell2.textContent||cell2.innerText;
								if(headtxt.indexOf("名称") != -1 || headtxt=="主力" || headtxt.indexOf("主题") != -1){
									val1 = val1;
									val2 = val2;
								}else if(headtxt.indexOf("连板") != -1){								
									val1 = val1.replace("昨日首板","-1").replace("首板","1").replace("连板","");
									if(val1.indexOf("天")>-1){
										val1 = val1.split("天")[0];
									}else if(val1.indexOf("昨")>-1){
										val1 = 0;
									}else if(val1 == ""){
										val1 = -2;
									}										
									val1 = parseFloat(val1);
								
									val2 = val2.replace("昨日首板","-1").replace("首板","1").replace("连板","");
									if(val2.indexOf("天")>-1){
										val2 = val2.split("天")[0];
									}else if(val2.indexOf("昨")>-1){
										val2 = 0;
									}else if(val2 == ""){
										val2 = -2;
									}									
									val2 = parseFloat(val2);
								}else if(headtxt.indexOf("领涨") != -1){
									val1 = val1.replace("龙十","龙一十").replace("破板","1000");
									val2 = val2.replace("龙十","龙一十").replace("破板","1000");
									if(val1 == ''){
										val1 = '1001';
									}
									if(val2 == ''){
										val2 = '1001';
									}
									if(val1.indexOf("龙") != -1){
										val1 = ChineseToNumber(val1.replace("龙",""));										
									}										
									if(val2.indexOf("龙") != -1){
										val2 = ChineseToNumber(val2.replace("龙",""));
										
									}
									//val2 = parseFloat(val2);									
								}else{
									if(val1 == "-"){
										val1 = " ";
									}
									if(val2 == "-"){
										val2 = " ";
									}
									val1 = val1.replace(" ","0").replace("无","1000").replace("NaN","0");
									val2 = val2.replace(" ","0").replace("无","1000").replace("NaN","0");
									if(val1.indexOf("万") != -1){
										val1 = parseFloat(val1)*10000;
									}else if(val1.indexOf("亿") != -1){
										val1 = parseFloat(val1)*100000000;
									}else{
										val1 = parseFloat(val1);
									}
									
									if(val2.indexOf("万") != -1){
										val2 = parseFloat(val2)*10000;
									}else if(val2.indexOf("亿") != -1){
										val2 = parseFloat(val2)*100000000;
									}else{
										val2 = parseFloat(val2);
									}
								}
								if(val1<val2){
									return -1;
								}else if(val1>val2){
									return 1;
								}else{
									return 0;
								}
								
							});
							if(flag){
								rows.reverse();								
							}
							
							for(var i=0;i<rows.length;i++){
								tbody.appendChild(rows[i]);
							}

							flag=!flag;
							f = f * (-1);
						}
					}(i));
				}
			}
			
			function showCol(iCol){			
				var oTable = document.getElementsByTagName('table')[0];
				for (i=0;i < oTable.rows.length; i++){										
					for (j=0;j < oTable.rows[0].cells.length; j++){
						oTable.rows[i].cells[j].style.color = "#E5E5E5";
						
						oTable.rows[i].cells[4].style.color = "#FFA500"; 
						oTable.rows[i].cells[5].style.color = "#FFA500";
						oTable.rows[i].cells[6].style.color = "#FFA500";										
					}
					oTable.rows[i].cells[iCol].style.color = "#FF6633";					
				}

				otagsA = oTable.getElementsByTagName("a");  //a变色
				for (i = 0; i < otagsA.length; i++) {
					otagsA[i].style.color = "#E5E5E5";
					if(otagsA[i].id >= 5){
						otagsA[i].style.color = "#FFA500";								
					}
					if(otagsA[i].id == iCol + 1){
						otagsA[i].style.color = "#FF6633";
					}
				}								
			}
			
			var chnNumChar = {零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9};

			var chnNameValue = {
			  十:{value:10, secUnit:false},
			  百:{value:100, secUnit:false},
			  千:{value:1000, secUnit:false},
			  万:{value:10000, secUnit:true},
			  亿:{value:100000000, secUnit:true}
			}

			function ChineseToNumber(chnStr){
			  var rtn = 0;
			  var section = 0;
			  var number = 0;
			  var secUnit = false;
			  var str = chnStr.split('');

			  for(var i = 0; i < str.length; i++){
				var num = chnNumChar[str[i]];
				if(typeof num !== 'undefined'){
				  number = num;
				  if(i === str.length - 1){
					section += number;
				  }
				}else{
				  var unit = chnNameValue[str[i]].value;
				  secUnit = chnNameValue[str[i]].secUnit;
				  if(secUnit){
					section = (section + number) * unit;
					rtn += section;
					section = 0;
				  }else{
					section += (number * unit);
				  }
				  number = 0;
				}
			  }
			  return rtn + section;
			}
			
			function updatez() {
				var dmz = bdm; 			 					
				var url3 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&ZZ=1&a=PlateIntroduction&st=30&c=ZhiShuRanking&Index=0&apiv=w24&Type=2&PlateID=" + dmz + "&"; 								
				if (window.XMLHttpRequest) {
				xmlHttp4 = new XMLHttpRequest();				
				} else {
				xmlHttp4 = new ActiveXObject("Microsoft.XMLHTTP");				
				}
				xmlHttp4.onreadystatechange = writeSource4;				
				xmlHttp4.open("GET", url3, true);
				xmlHttp4.send(null);				
			}
			
			function writeSource4() { 			
				if (xmlHttp4.readyState == 4) {                  	
				var data3 = xmlHttp4.responseText
				//document.write(data3);
				data3 = data3.replace(/ /g,"").match(/\{\"List\":(\S*)\]\],\"/)[1] + ']]';
				data3 = data3.replace(/(\[\").*?(?=\])/g,function(word){ 
				str = word.match(/\[(\S*)/)[1]; 
				return '{"code":' + str.split(',')[0] + 
				',"name":' + str.split(',')[1] + 
				',"zf":'+str.split(',')[3] + 
				',"lzcs":'+str.split(',')[4]});
				
				data3 = '{\"list\":' + data3.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]") + "}";				
				//document.write(data3);
				
				var transform_aa3 = [           
				{"tag":"p", children:function(){return(json2html.transform(this.list, transform_bb3));}}
				];
				
				var transform_bb3= 
				{"tag":"p", children:[
				{"tag":"p", children:[	
				{"tag": "p", "html":"<a href='http://www.treeid/code_${code}' onclick='changeCss(this,\"towrite3\");updated(this)'>${name}&nbsp;涨幅：${zf}%&nbsp;&nbsp;领涨：${lzcs}</a>"}, 
				]}]}; 
				
				var html3 = json2html.transform(data3, transform_aa3);	
				var bfyy = "<a style='padding-left:0px' href='javascript:void(0)' onclick='updateb()'>【原因】</a>";
				var qb = "<a style='float:right;margin-right:5px;' href='javascript:void(0)' onclick='update(" + "0" + ")'>全部</a>";				
				div2 = document.getElementById('towrite3');				
				//div2.innerHTML = '<h4>' + bkm + qb + '</h4>';
				div2.innerHTML = '<b>' + bkm + bfyy + qb + '</b>';					
				div2.innerHTML = div2.innerHTML + html3;
				div2.style.whiteSpace = "nowrap";
				}					
			}
			
			function updateb() {
				y = 0;	
				var dm = bdm; 			 
				//div2 = document.getElementById('towrite2');				
				//div2.innerHTML = '<h3>' + bk + '</h3>';
				var url4 = "https://apphq.longhuvip.com/w1/api/index.php?a=GetBaseFaceListZDEvnArtNew&apiv=w26&c=ZhiShuL2Data&StockID=" + dm;				
				var url5 = "https://apphis.longhuvip.com/w1/api/index.php?a=GetDayBaseFaceListZDEvnArt&st=10&c=ZhiShuKLine&apiv=w26&StockID=" + dm; 								
				if (window.XMLHttpRequest) {
				xmlHttp41 = new XMLHttpRequest();				
				} else {
				xmlHttp41 = new ActiveXObject("Microsoft.XMLHTTP");				
				}
				xmlHttp41.onreadystatechange = writeSource5;				
				xmlHttp41.open("GET", url4, true);
				xmlHttp41.send(null);
				
				if (window.XMLHttpRequest) {
				xmlHttp5 = new XMLHttpRequest();				
				} else {
				xmlHttp5 = new ActiveXObject("Microsoft.XMLHTTP");				
				}
				xmlHttp5.onreadystatechange = writeSource5;				
				xmlHttp5.open("GET", url5, true);
				xmlHttp5.send(null);								
			}
			
			function writeSource5() { 			
				if (xmlHttp41.readyState == 4 && xmlHttp5.readyState == 4) { 
					var data = xmlHttp41.responseText
					data = '{"List":[' + data + ']}';
					//document.write(data);	
					var fh = "<a style='padding-left:10px' href='javascript:void(0)' onclick='update(" + "0" + ")'>【返回】</a>";
					var zz = "<a style='float:right' href='javascript:void(0)' onclick='updatez()'>最正宗</a>";				
					div2 = document.getElementById('towrite3');				
					div2.innerHTML = '<h4>' + bkm + fh + zz + '</h4>';	
						
					if(data.indexOf('"Date":""') == -1)
					{
						var rq = data.match(/\"Date\":\"(\S*)\",\"/)[1];
						var day = new Date();
						gt = day.getTime();			
						mymonth = day.getMonth()+1;
						myday = day.getDate();
						if(mymonth >= 10){mymonth = mymonth;}else{mymonth = "0" + mymonth;}
						if(myday >= 10){myday = myday;}else{myday = "0" + myday;}
						tt = day.getFullYear() + "-" + mymonth + "-" + myday;													
						if(rq == tt){
							var transform_aa = [           
							{"tag":"p", children:function(){return(json2html.transform(this.List, transform_bb));}}
							];
							
							var transform_bb= 
							{"tag":"p", children:[
							{"tag":"li", children:[							
							{"tag": "b", "html":"${Date}：${BoomReason}"},
							{"tag": "p", "html":"${Title}"}, 								
							]}]}; 
							
							var html = json2html.transform(data, transform_aa);																						
							div2.innerHTML = div2.innerHTML + html;
						}
					}
					
					var data1 = xmlHttp5.responseText
					//document.write(data);				
					if(data1.indexOf('\"List\":[]') == -1)
					{
						var transform_aa = [           
						{"tag":"p", children:function(){return(json2html.transform(this.List, transform_bb));}}
						];
						
						var transform_bb= 
						{"tag":"p", children:[
						{"tag":"li", children:[							
						{"tag": "b", "html":"${Date}：${BoomReason}"},
						{"tag": "p", "html":"${Title}"}, 								
						]}]}; 
						
						var html = json2html.transform(data1, transform_aa);					
						<!-- var fh = "<a style='padding-left:0px' href='javascript:void(0)' onclick='update(" + "0" + ")'>【返回】</a>"; -->
						<!-- var zz = "<a style='float:right;margin-right:5px;' href='javascript:void(0)' onclick='updatez()'>最正宗</a>";				 -->
						<!-- div2 = document.getElementById('towrite3');				 -->
						<!-- div2.innerHTML = '<h4>' + bkm + fh + zz + '</h4>';													 -->
						div2.innerHTML = div2.innerHTML + html;
					}
					else if(data1.indexOf('\"List\":[]') > -1 && data.indexOf('"Date":""') > -1)
					{
						<!-- var fh = "<a style='padding-left:10px' href='javascript:void(0)' onclick='update(" + "0" + ")'>【返回】</a>"; -->
						<!-- var zz = "<a style='float:right;margin-right:5px;' href='javascript:void(0)' onclick='updatez()'>最正宗</a>";				 -->
						<!-- div2 = document.getElementById('towrite3');				 -->
						<!-- div2.innerHTML = '<h4>' + bkm + fh + zz + '</h4>';	 -->
						div2.innerHTML = div2.innerHTML + "暂无数据";	
					}	
					div2.style.whiteSpace = "normal";  //折行
				}					
			}
			
			function ranking(){
				//var alist = document.getElementById("towrite2").getElementsByTagName("a");
				var alist = document.querySelectorAll("#towrite2 > p :first-child")
				if (alist.length >=2) {
					for(var i = 0; i < alist.length; i++){
					yy = yy.replace(/ /g,"");
					var bk = alist[i].id;

					bk = bk.replace("%","");// 华是科技的板块为CMP/MPO，但是显示为CMP%/MPO,导致匹配不出来，所以这里将板块中的%去除掉 update by -gaoth
					var y1 = "";
					var y2 = "";
					if(yy.indexOf("+")>-1){
						y1 = yy.split("+")[0];
						y2 = yy.split("+")[1];
					}else if(yy.indexOf("(")>-1){
						y1 = yy.split("(")[0];
						y2 = yy.split("(")[1].split(")")[0];
					}else{
						y1 = yy;
					}


					// 精选板块2个着色
					var bk1 = "";
					var bk2 = "";
					if(bk2g.indexOf("、")>-1) {
						bk1 = bk2g.split("、")[0];
						bk2 = bk2g.split("、")[1];
					}
					if(bk != ""){
						if(y1 == bk || y2 == bk){

							alist[i].style.color = "#FFA500";
						}
						if(bk2 == bk ){
							alist[i].style.color = "#FF6633";
						}
						if(bk1 == bk ){
							alist[i].style.color = "#FF6633";
						}
					}

				}
				}

			}
			
		</script>	
	</body>
</html>